package log

import (
	"bytes"
	"sync"
)

var (
	bufPool = &bufferPool{
		pool: &sync.Pool{
			New: func() any {
				return new(bytes.Buffer)
			},
		},
	}
)

type bufferPool struct {
	pool *sync.Pool
}

func (p *bufferPool) Put(buf *bytes.Buffer) {
	p.pool.Put(buf)
}

func (p *bufferPool) Get() *bytes.Buffer {
	return p.pool.Get().(*bytes.Buffer)
}
